package idea.think.custom_ui;

import idea.think.R;
import idea.think.adapter.CustomIdeaAdapter;
import idea.think.vo.IdeaData;

import java.util.ArrayList;

import android.app.DialogFragment;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

/**
 * @author Kim ji ho
 * 커스텀 다이알로그 프래그먼트
 */
public class CustomDialogFragment extends DialogFragment implements OnEditorActionListener {

	private int mResource;
	private String mTitle;
	private Object mObj;
	private Context mContext;
	private OnClickListener mListener;
	
	public CustomDialogFragment(Context context, int resource, String title, Object obj, OnClickListener listener){
		this.mResource = resource;
		this.mTitle = title;
		this.mObj = obj;
		this.mContext = context;
		this.mListener = listener;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(this.mResource, container);
		getDialog().setTitle(mTitle);
		
		ListView list = (ListView) view.findViewById(R.id.ideaListView);
		CustomIdeaAdapter ideaAdapter = (CustomIdeaAdapter)mObj;
		ideaAdapter.notifyDataSetChanged();
		list.setAdapter(ideaAdapter);
		
		((Button)view.findViewById(R.id.ideaListBtnDel)).setOnClickListener(mListener);
		((Button)view.findViewById(R.id.ideaListCloseDel)).setOnClickListener(mListener);
		
		return view;
	}
	
	@Override
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		// TODO Auto-generated method stub
		return false;
	}

}
